package com.zjw.zy.componse.demo.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import com.zjw.zy.componse.demo.ext.back


/**
 * @author     ：zhong.jw
 * @date       ：Created in 2023/2/16 10:08
 * @description：
 */
abstract class BaseComposeFragment : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
    ): View {
        return ComposeView(requireContext()).apply {
            onContentView(this)
        }
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        onSubscribeValue()
    }

    abstract fun onContentView(rootView: ComposeView)

    abstract fun onSubscribeValue()

    open fun onBackPress() {
        back()
    }
}
